import { createRouter, createWebHistory} from 'vue-router'
import IndexView from '../views/IndexView.vue'
import LoginView from '../views/LoginView.vue'

const routes = [
  {
    path: '/',
    name: 'home',
    component: IndexView
  },
  {
    path: '/sysView',
    name: 'sys',
    component: () => import('../views/SysView.vue')
  },
  {
    path: '/menuView',
    name: 'menu',
    component: () => import('../views/MenuView.vue')
  },
  {
    path: '/funcView',
    name: 'func',
    component: () => import('../views/FuncView.vue')
  },
  {
    path: '/orgView',
    name: 'org',
    component: () => import('../views/OrgView.vue')
  },
  {
    path: '/positionView',
    name: 'job',
    component: () => import('../views/PositionView.vue')
  },
  {
    path: '/userView',
    name: 'user',
    component: () => import('../views/UserView.vue')
  },
  {
    path: '/roleView',
    name: 'role',
    component: () => import('../views/RoleView.vue')
  },
  {
    path: '/log/loginView', 
    name: 'loginLog',
    component: () => import('../views/LoginLogView.vue')
  },
  {
    path: '/log/serviceView', 
    name: 'logService',
    component: () => import('../views/ServerLogView.vue')
  },
  {
    path: '/svipConfigView', 
    name: 'svipConfig',
    component: () => import('../views/VipConfigView.vue')
  },
  {
    path: "/compositeUserQueryView",
    name: "compositeUserQuery",
    component: () => import("../views/AccountView.vue")
  },
  {
    path: "/resourceTypeView", 
    name: "resourceType", 
    component: () => import("../views/ResourceTypeView.vue")
  },
  {
    path: "/resourceView", 
    name: "resource", 
    component: () => import("../views/ResourceView.vue"), 
    props:(route) => {  // 将状态 通过 props 进行绑定，实现 组件和 router的解耦
       return {
          state: route.query.state, 
          action: route.query.a 
       }
    }
  },
  {
    path: "/commentView" ,
    name: "comment", 
    component: () => import("../views/CommentView.vue"), 
    props:(route) => {  // 将状态 通过 props 进行绑定，实现 组件和 router的解耦
       return {
          state: route.query.state, 
          action: route.query.a 
       }
    }
  },
  {
    path: "/swiperView",
    name: "swiper",
    component: () => import("../views/SwiperView.vue")
  },
  {
    path: "/advertView", 
    name: "advert" ,
    component : () => import("../views/AdvertView.vue")
  },
  {
    path: "/officialAdviceView", 
    name: "officialAdvice", 
    component: () => import("../views/OfficialAdviceView.vue")
  },
  {
    path: "/scoreConfigView", 
    name: "scoreConfig", 
    component: () => import("../views/ScoreConfigView.vue")
  },
  {
    path: '/:catchAll(.*)',
    name: 'notFound',
    component: () => import('../views/404.vue')
  }
]

const router = createRouter({
  history: createWebHistory(),
  routes
})

export default router
